package main

import (
	"fmt"
	"io"
	"os"
	"path/filepath"
)

func main() {

	fileInfo, err := os.Stat("aaa.txt")
	if err != nil {
		fmt.Println("err:", err)
		return
	}

	fmt.Printf("%T\n", fileInfo)
	fmt.Println(fileInfo.Name())
	fmt.Println(fileInfo.IsDir())

	abs := filepath.IsAbs("1111")
	println(abs)

	file, err := os.Open("aaa.txt")
	if err != nil {
		fmt.Println("err:", err)
	}

	defer file.Close()

	bs := make([]byte, 4, 4)
	n := -1
	for {
		n, err = file.Read(bs)
		if n == 0 || err == io.EOF {
			fmt.Println("读取到文件末尾")
			break
		}

		fmt.Println(string(bs[:n]))
	}
}
